<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%--create by yangyafei on 2017年9月8日--%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>js/jquery专项</title>
<link rel="stylesheet" href="http://cdn.amazeui.org/amazeui/2.7.2/css/amazeui.min.css" />
		
	</head>
	<body>
		<div class="am-container dataDiv">
			<section class="am-panel am-panel-primary">
			  <header class="am-panel-hd">
			    <h3 class="am-panel-title">考试功能演示</h3>
			  </header>
			  <div class="am-panel-bd" >
					<table class="am-table am-table-bordered am-text-center">
						<thead>
							<tr>
								<th colspan="3">
									<button title="点击此按钮刷新下方表格数据，ajax处理" type="button"  id="aaa" class="am-btn am-btn-primary">刷新数据</button>
								</th>
							</tr>
							
						</thead>
						<tbody id="bb">
						<c:forEach items="${Admin }" var="a" varStatus="index">
							<tr>
							 <td><input type="checkbox" id="checks" name="checkboxs" value="${a.id }"  ></td>
								<td>${a.name }</td>
								<td>${a.age }</td>
							</tr>
							
							</c:forEach>
							
							
							<tr>
								
								<td colspan="3">
									<button class="am-btn am-btn-primary" title="点击后将所有数据的checkbox修改为选中状态" type="button"  id="check" onclick='return checkAll();'  >全选</button>
									<button class="am-btn am-btn-primary" title="点击后将所有数据的checkbox修改为未选中状态"  type="button"  id="checkNo" onclick='return checkNoAll();'>全不选</button>
									<button class="am-btn am-btn-primary" title="点击后，已选择的checkbox改为未选择，未选择的checkbox改为已选择"  onclick='return checkOther();'>反选</button>
									<button class="am-btn am-btn-warning" title="点击后提交已选择数据的value值" id="aaaa" >提交已选择数据</button>
								</td>
							</tr>
						</tbody>
					</table>
					<div>
						<p>点击提交按钮后，如果未选择任何数据，在这里打印提示信息，提示用户先选择数据再提交</p>
						<p>如果已选择数据，则提交并且在后台打印提交的所有数据。然后将当前项目的运行路径获取并且返回，在这里显示了</p>
					</div>
			  </div>
			</section>
		</div>
		
		
		<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js "></script>
		<script src="http://cdn.amazeui.org/amazeui/2.7.2/js/amazeui.min.js "></script>
		

<script type="text/javascript">

$(function(){
	
	$('#aaa').on('click',function(){
		var a=1;
		console.log('aaaa');
		$('#bb').load('query.do');
		
		console.log('aaaa');
	});
	
	
	$('#aaaa').on('click',function(){
	
		var checkboxs=document.getElementsByName('checkboxs');
	
		for(i=0;i<checkboxs.length;i++){
			
			if(checkboxs[i].checked){
				console.log('aaaa');
				break;
			}
			
			else{
				alert('请选择数据后再提交');
				
			}
			
				
		}
	});
})


</script>
<script type="text/javascript">

function checkAll(){
	var checkboxs=document.getElementsByName('checkboxs');
	console.log('qqqqqqq');
	for(i=0;i<checkboxs.length;i++){
		
		var b=checkboxs[i];
		
			b.checked=true;
		
	}
	
}

</script>


<script type="text/javascript">
function checkNoAll(){
	var checkboxs=document.getElementsByName('checkboxs');
	
	for(i=0;i<checkboxs.length;i++){
		
		var b=checkboxs[i];
		
			b.checked=false;
		
	}
	
}

</script>


<script type="text/javascript">
function checkOther(){
	var checkboxs=document.getElementsByName('checkboxs');
	console.log('qqqqqqq');
	for(i=0;i<checkboxs.length;i++){
		console.log(checkboxs[i]);
		if(checkboxs[i].checked){
		var a=checkboxs[i].value;
		
			console.log(a);
			
			
			
			checkNoAll();
		}
		
			
		
	}
	
}

</script>
</body>
</html>